using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Text;
using System.Collections.Generic;

namespace trainstorm.InstanceClass
{
	public class Boss
	{
		private Vector2 pos;
		private Texture2D gambar;
		private float damage;
		private float hp;
		private float rate;
		private Texture2D attack;
		private int dir;
		private float draining;
		private float rejuvenate;

		// constructor
		public Boss()
		{
			pos = new Vector2(0, 0);
			gambar = null;
			damage = 0;
			attack = null;
			dir = 0;
		}
		public Boss(Game1 game1, int bossNumber)
		{
			gambar = game1.getInsManager().getBoss(bossNumber);
			damage = 1f; //game1.getInsManager().getBossDmg((bossNumber * 3));
			hp = 1f; //game1.getInsManager().getBossDmg((bossNumber * 3) + 1);
			rate = 1f; //game1.getInsManager().getBossDmg((bossNumber * 3) + 2);
			attack = game1.getInsManager().getBossATK(bossNumber);
			pos = new Vector2(800, 80);
			dir = 0;
			draining = 0;	//belum tau isinya apa
			rejuvenate = 0;	//belum tau isinya apa
		}

		//getter setter
		public float getX()
		{
			return pos.X;
		}
		public float getY()
		{
			return pos.Y;
		}
		public Texture2D getSprite()
		{
			return gambar;
		}
		public float getDamage()
		{
			return damage;
		}
		public Obstacle getAttack()
		{
			return new Obstacle(pos.X, pos.Y + (gambar.Height / 2f), attack);
		}
		public float getHP()
		{
			return hp;
		}

		public void setX(float x)
		{
			pos.X = x;
		}
		public void setY(float y)
		{
			pos.Y = y;
		}
		public void setSprite(Texture2D sprite)
		{
			gambar = sprite;
		}

		public void setDamage(float dmg)
		{
			damage = dmg;
		}

		public void drain()
		{
			hp -= draining;
		}
		public void regenerate()
		{
			hp += rejuvenate;
		}

		//update
		public void Update(GameTime gameTime)
		{
			if (pos.X > 561)
				pos.X -= ((float)(gameTime.ElapsedGameTime.TotalSeconds) * 27);
			else
			{
				if (dir == 0)
				{
				    if (pos.Y < 190)
					{
				        pos.Y += ((float)(gameTime.ElapsedGameTime.TotalSeconds) * 27);
				        if (pos.Y > 190)
				            pos.Y = 190;
					}
				    else
				        dir = 1;
				}
				else
				{
				if (pos.Y > 0)
				{
					pos.Y -= ((float)(gameTime.ElapsedGameTime.TotalSeconds) * 27);
					if (pos.Y < 0)
						pos.Y = 0;
				}
				else
					dir = 0;
				}
				
			}

		}

		//draw
		public void Draw(SpriteBatch batch)
		{
			//batch.Draw(gambar, pos, null, Color.White);
			batch.Draw(gambar, pos, null, Color.White, 0f, Vector2.Zero, 0.6f, SpriteEffects.None, 1f);
		}
	}
}
